package system;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class AddOperation implements Operation{
    public Book getBookOperation(){
        Scanner scan = new Scanner(System.in) ;
        System.out.println("请输入书名");
        String name = scan.nextLine() ;
        System.out.println("请输入作者");
        String writer = scan.nextLine() ;
        System.out.println("请输入价格");
         int money = scan.nextInt() ;
         return new Book(name,writer,money) ;
    }

    @Override
    public void work(BookList bookList) {
        System.out.println("添加图书");
        if(bookList.getBookListMax() == bookList.getUsedSize()){
            System.out.println("书架已满,无法添加");
            return ;
        }else{
            Book book = getBookOperation() ;
            bookList.setBook(bookList.getUsedSize(),book);
            bookList.setUsedSize(bookList.getUsedSize() + 1);
        }
    }


}
